home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 255_01 / gpslope.asm < prev    next >
Encoding:
Assembly Source File  |  1988-03-28  |  2.3 KB  |  81 lines

  1.           page   80,132
  2.           page
  3. ;
  4. ;         Kent Cedola
  5. ;         2015 Meadow Lake Court
  6. ;         Norfolk, Virginia  23518
  7. ;
  8.  
  9. dgroup    group  _data
  10.  
  11. _data     segment word public 'data'
  12.           assume ds:dgroup
  13. _data     ends
  14.  
  15. _text     segment byte public 'code'
  16.  
  17.           assume cs:_text,ds:dgroup
  18.           public _gpslope
  19. _gpslope  proc   near
  20.  
  21.           push   bp
  22.           mov    bp,sp
  23.           push   si
  24.           push   di
  25.  
  26.           push   ds                    ; Set ES equal to DS so we can use the
  27.           pop    es                    ;   ... STOSB instruction
  28.  
  29.           mov    di,[bp+4]             ; Clear the output slope array
  30.           mov    cx,[bp+6]             ;   Load number of bytes in array
  31.           xor    al,al                 ;   Fill with zeros (AL)
  32.           rep stosb                    ;   Fill the slope array with zeros
  33.  
  34.           mov    di,[bp+4]             ; Load address of the slope array
  35.           mov    bx,[bp+6]             ; Load Delta X (for slope calculations)
  36.           mov    dx,[bp+8]             ; Load Delta Y (for slope calculations)
  37.  
  38.           cmp    dx,bx
  39.           ja     octant2
  40. octant1:
  41.           mov    cx,bx
  42.           dec    cx
  43.           mov    si,bx                 ; Error Register = -DX/2
  44.           shr    si,1                  ;   ...
  45.           neg    si                    ;   ...
  46. octant1L:
  47.           add    si,dx
  48.           js     octant1E
  49.           sub    si,bx
  50.           inc    al
  51. octant1E:
  52.           stosb
  53.           xor    al,al
  54.           loop   octant1L
  55.           jmp    short return
  56.  
  57. octant2:
  58.           mov    cx,dx
  59.           dec    cx
  60.           mov    si,dx                 ; Error Register = -DY/2
  61. ;         shr    si,1                  ;   ...
  62.           neg    si                    ;   ...
  63. octant2L:
  64.           inc    byte ptr [di]
  65.           add    si,bx
  66.           js     octant2E
  67.           sub    si,dx
  68.           inc    di
  69. octant2E:
  70.           loop   octant2L
  71.           inc    byte ptr [di]
  72. return:
  73.           pop    di
  74.           pop    si
  75.           pop    bp
  76.           ret
  77.  
  78. _gpslope  endp
  79.  
  80. _text     ends
  81.           end